﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TireBias.Models.BIASPLANModel.BIASPLAN_DS>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    New_Sample_PROC</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table width="98%" class="shadow">
        <tr>
            <td colspan="2" style="background-color: #E46C0A; color: White; font-size: xx-large;
                text-align: center;">
                New Sample&nbsp; <span class="fontTh">(ผ้าใบทดลอง)</span>
            </td>
        </tr>
        <tr class="rowb">
            <td class="head cell text-right" style="width: 35%; padding: 10px 0px;">
                Size &nbsp;<span class="fontTh">ขนาดผ้าใบ</span>
            </td>
            <td class="cell">
                <%: Model._Size %>
            </td>
        </tr>
        <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px;">
                Forming&nbsp;<span class="fontTh">เครื่องที่สร้าง</span>
            </td>
            <td class="cell">
                <%: Model._Forming %>
            </td>
        </tr>
        <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px;">
                Topped Cord &nbsp;<span class="fontTh">ชนิดผ้าใบ</span>
            </td>
            <td class="cell">
                <%: Model._Topcrdcd  %>
            </td>
        </tr>
        <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px;">
                Tire Cord Lot <span class="fontTh">ล็อตผ้าใบ</span>
            </td>
            <td class="cell">
                <%: Model._tcrdlot %>
            </td>
        </tr>
        <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px;">
                Expired date <span class="fontTh">วันหมดอายุ</span>
            </td>
            <td class="cell">
                <%: Model._topexp %>
            </td>
        </tr>
        <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px;">
                Length (M.) &nbsp;<span class="fontTh">ความยาว (เมตร)</span>
            </td>
            <td class="cell">
                <%: Model._toplen %>
            </td>
        </tr>
        <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P1) && Convert.ToInt32(Model._P1)>0)
           { %>
        <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px;">
                <span>P1</span> M. <span class="fontTh">(เมตร)</span>
            </td>
            <td class="cell" id="Td1">
                <%: Model._P1%>
            </td>
        </tr>
        <%} %>
        <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P2) && Convert.ToInt32(Model._P2) > 0)
           { %>
        <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px;">
                <span>P2</span> M. <span class="fontTh">(เมตร)</span>
            </td>
            <td class="cell" id="Td2">
                <%: Model._P2%>
            </td>
        </tr>
        <%} %>
        <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P3) && Convert.ToInt32(Model._P3) > 0)
           { %>
        <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px;">
                <span>P3</span> M. <span class="fontTh">(เมตร)</span>
            </td>
            <td class="cell" id="Td3">
                <%: Model._P3%>
            </td>
        </tr>
        <%} %>
        <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P4) && Convert.ToInt32(Model._P4) > 0)
           { %>
        <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px;">
                <span>P4</span> M. <span class="fontTh">(เมตร)</span>
            </td>
            <td class="cell" id="Td4">
                <%: Model._P4 %>
            </td>
        </tr>
        <%} %>

            <tr class="rowb hide" id="ang">
                <td class="head cell text-right" style="padding: 10px 0px;">
                <span></span> Angle          
                <span class="fontTh">องศาผ้าใบ </span><span></span>
                </td>
                <td class="cell" id="Td10">
               
                </td>
            </tr>
              <tr class="rowb hide" id="width">
                <td class="head cell text-right" style="padding: 10px 0px;">
                <span></span> Width          
                <span class="fontTh">ความกว้าง </span><span></span>
                </td>
                <td class="cell" id="Td5">
               
                </td>
            </tr>
    </table>
    <input type="hidden" id="subItem" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="TableContent" runat="server">
    <div class="float-left" style="margin-left: 50px;">
 <input type="button" id="new" value="NewPLY" class="btnFooter"  
              style="height: 75px;  width: 350px;" />

         
        
</div><div class="float-right" style="margin-right: 50px;"> 
<input type="button" id="fin" value="FINISHED" class="btnFooter"  
              style="height: 75px;  width: 350px;" /></div>

</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="ScriptsSection" runat="server">
    <style type="text/css">
.hide
{
    display:none;
}

</style>
<script type="text/javascript">
    $(function () {
        $("#new").click(function () {
            var url = '<%: Url.Action("New_Sample")%>';
            window.location = url + '?seq=' + '<%= Model._Plandt %>' + "-" + '<%=Model._Itemno %>';
        });
        function callScriptMethod(url, jsonObject, action, callback, async) {

            callback = callback || function () { };
            async = (async == null || async);

            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: url,
                data: JSON.stringify(jsonObject),
                dataType: "json",
                async: async,
                success: function (data) {

                    if (data.success != "0") {
                        var getUsersUrl = '<%= Url.Action("Header_line","BiasHead") %>' + '?biasno=' + '<%: Model._Biasno %>' + '&shift=' + '<%: Model._Shift %>';

                        window.location = getUsersUrl;
                    } else alert(data.message);
                },
                error: function (xhr, status, error) {
                    var err = xhr.responseText;
                    alert(err.Message);
                }
            });
        }

        $("#fin").click(function () {
            var dataForSubmit = new Array();
            dataForSubmit.push({
                _biasno: '<%: Model._Biasno %>',
                _plandt: '<%: Model._Plandt %>',
                _itemno: '<%: Model._Itemno %>',
                _empname: '<%: User.Identity.Name %>',
                _shift: '<%: Model._Shift %>',
                _sitemno: $("#subItem").val()
            });
            var getUsersUrl = '<%= Url.Action("FINIS_TireSTD") %>';
            callScriptMethod(getUsersUrl, { theData: dataForSubmit }, 'ADD');
        });

        $.post('<%=Url.Action("Get_Value","BiasHead_KANBAN") %>' + '?seq=' + '<%= Model._Plandt %>' + "-" + '<%=Model._Itemno %>' + '&biasno=' + '<%= Model._Biasno %>' + '&shift=' + '<%= Model._Shift %>'
      , function (data) {
          if (data.success == 1) {
              $("#subItem").val(data.subItem);
              $("#ply1").text(data.ply1);
              $("#ply2").text(data.ply2);


              if (data.ply2 != "") {
//                  var tr = $("#ang").clone(true).removeClass("hide").addClass("ang");
//                  tr.find("span:first").text(data.ply2 + ' ');
//                  tr.find("span:last").text(' ' + data.ply2.replace("P", ""));
//                  tr.find("td:last").html(data.aPly2);
//                  $("#ang").after(tr);
                  var tr1 = $("#width").clone(true).removeClass("hide").addClass("width");
                  tr1.find("span:first").text(data.ply2 + ' ');
                        
                  tr1.find("td:last").html(data.w2);
                  $("#width").after(tr1);

              }
              if (data.ply1 != "") {
                  var tr = $("#ang").clone(true).removeClass("hide").addClass("ang");
//                  tr.find("span:first").text(data.ply1 + ' ');
//                  tr.find("span:last").text(' ' + data.ply1.replace("P", ""));
                  tr.find("td:last").html(data.aPly1);
                  $("#ang").after(tr);
                  var tr1 = $("#width").clone(true).removeClass("hide").addClass("width");
                   tr1.find("span:first").text(data.ply1 + ' ');
                                 
                  tr1.find("td:last").html(data.w1);
                  $("#width").after(tr1);


              }
          }
      });
    });
</script>
</asp:Content>
